package com.dq.controller;

import com.dq.pojo.PlanList;
import com.dq.service.Impl.PlanListServiceImpl;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import io.swagger.annotations.Api;

import javax.annotation.Resource;

/**
 * (PlanList)表控制层
 *
 * @author thinknovo
 * @since 2024-01-19 14:36:19
 */
@RestController
@RequestMapping("/planList")
@Api(value = "(PlanList)",tags = "(PlanList)接口API")
public class PlanListController {
    /**
     * 服务对象
     */
    @Resource
    private PlanListServiceImpl planListServiceImpl;

    /**
     * 一次性全部查询
     *
     * @return 查询结果
     */
//    @GetMapping("/selectAll")
    public Map<String, Object> selectAll() {
        return planListServiceImpl.selectAll();
    }

    /**
     * 分页查询
     *
     * @param planList 筛选条件
     * @param page        要查询第几页
     * @param limit       每页显示多少条
     * @return 查询结果
     */
    @GetMapping("")
    public Map<String, Object> selectByLimit(PlanList planList, @RequestParam int page, @RequestParam int limit) {
        return planListServiceImpl.selectByLimit(planList, page, limit);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
//    @GetMapping("/selectById")
    public Map<String, Object> selectById(@RequestParam Integer id) {
        return planListServiceImpl.selectById(id);
    }

    /**
     * 新增数据
     *
     * @param planList 实体
     * @return 新增结果
     */
    @PostMapping("")
    public Map<String, Object> insert(@RequestBody PlanList planList) {
        return planListServiceImpl.insert(planList);
    }

    /**
     * 编辑数据
     *
     * @param planList 实体
     * @return 编辑结果
     */
    @PutMapping("")
    public Map<String, Object> updateById(@RequestBody PlanList planList) {
        return planListServiceImpl.updateById(planList);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/{id}")
    public Map<String, Object> deleteById(@PathVariable Integer id) {
        return planListServiceImpl.deleteById(id);
    }

}

